package com.example.kotlincomponent

import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.SeekBar
import com.example.utils.BaseActivity
import kotlinx.android.synthetic.main.activity_progress.*

class ProgressActivity:BaseActivity() {
    private val TAG = "ProgressActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_progress)

        pb_progress_loading
        val seekBarListener = object :SeekBar.OnSeekBarChangeListener{
            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
//                TODO("Not yet implemented")
            //滑杆移动
                Log.d(TAG, "移动滑杆")
            }

            override fun onStartTrackingTouch(seekBar: SeekBar?) {
//                TODO("Not yet implemented")
            //按下滑杆
                Log.d(TAG, "按下滑杆")
            }

            override fun onStopTrackingTouch(seekBar: SeekBar?) {
                //离开滑杆的时候
//                TODO("Not yet implemented")
                Log.d(TAG, "停止移动")
                val len= sb_progress_loading.progress
                pb_progress_loading.progress=len
                //判断是否达到最大值
                if (len==sb_progress_loading.max)
                    ll_progress_loading.visibility= View.GONE
                else
                    ll_progress_loading.visibility=View.VISIBLE
            }

        }
        sb_progress_loading.setOnSeekBarChangeListener(seekBarListener)
    }
}